<?php

namespace App\Http\Responses;

use Illuminate\Http\Resources\Json\Resource as BaseResource;


class Resource extends BaseResource
{

    public static function collection($resource)
    {


        return new class($resource, get_called_class()) extends ResourceCollection {
            /**
             * @var string
             */
            public $collects;

            /**
             * Create a new anonymous resource collection.
             *
             * @param  mixed  $resource
             * @param  string  $collects
             * @return void
             */
            public function __construct($resource, $collects)
            {
                $this->collects = $collects;

                parent::__construct($resource);
            }
        };


    }

    public function toResponse($request)
    {
        return (new ResourceResponse($this))->toResponse($request);
    }


}